package com.jy.rhin.infra.repo.notfication.receive.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.jy.rhin.domain.notification.receive.entity.ReceiveMessageDO;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @author dhl
 * @date 2022/6/28
 * @Description 基础服务消息接收数据对象
 */
@Data
@NoArgsConstructor
@TableName("t_notification_message")
public class ReceiveMessagePO {

    public ReceiveMessageDO toDO() {
        ReceiveMessageDO receive = new ReceiveMessageDO();
        receive.setId(this.id);
        receive.setMsgId(this.msgId);
        receive.setContent(this.content);
        receive.setPublisherCode(this.publisherCode);
        receive.setTopicId(this.topicId);
        receive.setPublishTime(this.publishTime);
        receive.setCreateTime(this.createTime);
        return receive;
    }

    /**
     * do -> po 并给主键id
     * @param id
     * @param receive
     */
    public ReceiveMessagePO(Long id, ReceiveMessageDO receive){
        this.id = id;
        this.msgId = receive.getMsgId();
        this.topicId = receive.getTopicId();
        this.content = receive.getContent();
        this.publisherCode = receive.getPublisherCode();
        this.publishTime = receive.getPublishTime();
        this.createTime = receive.getCreateTime();
    }

    /**
     * 唯一标识
     */
    @TableId
    private Long id;
    /**
     * 主题id
     */
    @TableField("topic_id")
    private Long topicId;
    /**
     * 业务方消息标识id
     */
    @TableField("msg_id")
    private String msgId;
    /**
     * 消息内容
     */
    @TableField("content")
    private String content;
    /**
     * 参与者编码
     */
    @TableField("publisher_code")
    private String publisherCode;
    /**
     * 参与者消息发送时间
     */
    @TableField("publish_time")
    private Date publishTime;
    /**
     * 消息创建时间
     */
    @TableField("create_time")
    private Date createTime;


}
